/**
 * 统计分析
 * @type {Array}
 */
//数据总览的最新数据,学校的下拉列表的数据
var tableData = [],schoolDataAll = [],schoolDataList = [],schoolTableData = [];
//智能学生证激活量、2.4G考勤卡激活量、缴费量、x轴数据、学校柱状图、显示的视图
var intelligentData = [],cardData = [],payPraceData = [],xAxisData = [],addresData = [],addresDataOth = [],ThiPointFXData = [],option = "",schoolDetailsTableData = [],pageView = {schoolBarView:false,schoolTableView:false,clsaaTableView:false};
//表单组件
var Table = React.createClass({
    render: function () {
        return (
            <tr>
                <td className="table-tr-left-border">{this.props.devicetypename}</td>
                <td className="table-tr-left-border activation">{this.props.devicecounts}</td>
                <td className={this.props.validcounts==null?"table-tr-left-border contentIsNull":"table-tr-left-border pay "}><span>{this.props.validcounts==null?"":this.props.validcounts}</span></td>
                <td className={this.props.paycounts==null?"table-tr-left-border contentIsNull":"table-tr-left-border"}><span>{this.props.paycounts==null?"":this.props.paycounts}</span></td>
            </tr>
        );
    }
});
/**
 * 学校表单组件
 * @type {*}
 */
var SchoolTable = React.createClass({
    render: function () {
        return (
            <tr>
                <td style={{width: '5%'}}>{parseInt(this.props.listNumber)+1}</td>
                <th style={{width: '10%'}}>{this.props.trData.province+' '+this.props.trData.city+' '+this.props.trData.town}</th>
                <td style={{width: '12%'}}>{this.props.trData.schoolname}</td>
                <td style={{width: '12%'}}>{this.props.trData.discounttime}</td>
                <td style={{width: '8%'}}>{this.props.trData.devicetypename}</td>
                <td style={{width: '9%'}}>{this.props.trData.cardsendcounts}</td>
                <td style={{width: '9%'}}>{this.props.trData.cardvalidcounts}</td>
                <td style={{width: '9%'}}>{this.props.trData.devicesendcounts}</td>
                <td style={{width: '9%'}}>{this.props.trData.devicevalidcounts}</td>
                <td style={{width: '9%'}}>{this.props.trData.devicepaycounts}</td>
                <td style={{width: '8%'}}><div className="select trButton trLeft" onClick={this.props.onClickSelectSchool}>查看</div></td>
            </tr>
        );
    }
});
/**
 * 学校明细表单组件
 * schoolDetailsTableData
 * @type {*}
 */
var SchoolDetailsTable = React.createClass({
    render: function () {
        return (
            <tr>
                <td style={{width: '9%'}}>{parseInt(this.props.listNumber)+1}</td>
                <td style={{width: '15%'}}>{this.props.classname==null?"无":this.props.classname}</td>
                <td style={{width: '15%'}}>{this.props.teachertel==null?"无":this.props.teachertel}</td>
                <td style={{width: '13%'}}>{this.props.teachername==null?"无":this.props.teachername}</td>
                <td style={{width: '12%'}}>{this.props.cardsendcounts}</td>
                <td style={{width: '12%'}}>{this.props.cardvalidcounts}</td>
                <td style={{width: '12%'}}>{this.props.devicevalidcounts}</td>
                <td style={{width: '12%'}}>{this.props.devicepaycounts}</td>
            </tr>
        );
    }
});
var Main = React.createClass({
    getInitialState: function () {
        return {
            tableData:this.props.tableData,
            intelligentData:this.props.intelligentData,
            cardData:this.props.cardData,
            payPraceData:this.props.payPraceData,
            xAxisData:this.props.xAxisData,
            schoolDataAll:this.props.schoolDataAll,
            schoolDataList:this.props.schoolDataList,
            addresData:this.props.addresData,
            addresDataOth:this.props.addresDataOth,
            ThiPointFXData:this.props.ThiPointFXData,
            pageView:this.props.pageView,
            schoolTableData:this.props.schoolTableData,
            schoolDetailsTableData:this.props.schoolDetailsTableData
        }
    },
    /**
     * 初始化
     */
    componentDidMount: function () {
        var param="param={";
        //param = getJsonDataNotEmpty(param,"phone",$("#sim-phone").val());
        //param = getJsonDataNotEmpty(param,"status",$("#sim-status").val());
        param += "}";
        tableData=[];
        var svar = this;
        this.getStatDeviceList('');//获取数据总览
        suixun.ajax(serverUrl+'/workspaceManager/statDeviceListByDate.json','',"get",function(data){
            if(data.code == 200){
                var i=0,maxNumber = 0;
                for(var key in data.info[0]){
                    if(data.info[0][key].validcounts!=null && data.info[0][key].validcounts > maxNumber){
                        maxNumber = data.info[0][key].validcounts;
                    }
                    intelligentData[i]=data.info[0][key].validcounts!=null?data.info[0][key].validcounts:0;
                    xAxisData[i++]=key;
                }
                i=0;
                for(var key in data.info[1]){
                    if(data.info[1][key].validcounts!=null && data.info[1][key].validcounts > maxNumber){
                        maxNumber = data.info[1][key].validcounts;
                    }
                    cardData[i++]=data.info[1][key].validcounts!=null?data.info[1][key].validcounts:0;
                }
                i=0;
                for(var key in data.info[2]){
                    if(data.info[2][key].paycounts!=null && data.info[2][key].paycounts > maxNumber){
                        maxNumber = data.info[2][key].paycounts;
                    }
                    payPraceData[i++]=data.info[2][key].paycounts!=null?data.info[2][key].paycounts:0;
                }
                i=0;
                for(var key in data.info[3]){
                    if(data.info[3][key].validcounts!=null && data.info[3][key].validcounts > maxNumber){
                        maxNumber = data.info[3][key].validcounts;
                    }
                    ThiPointFXData[i++]=data.info[3][key].validcounts!=null?data.info[3][key].validcounts:0;
                }
                svar.setState({cardData:cardData,intelligentData:intelligentData,payPraceData:payPraceData,xAxisData:xAxisData,ThiPointFXData:ThiPointFXData});
                svar.setOption(maxNumber);
            }
        });
        suixun.ajax(serverUrl+'/schoolManage/querySchool.json','',"get",function(data){
            if(data.code == 200 ){
                for(var i=0;i<data.info.length;i++){
                    var obj=data.info[i];
                    schoolDataList[i] = {key:i,id:obj.id,schoolname:obj.schoolname};
                }
                schoolDataAll = schoolDataList;
                svar.setState({schoolDataList:schoolDataList,schoolDataAll:schoolDataAll});
            }else{
                svar.setState({schoolDataList:schoolDataList,schoolDataAll:schoolDataAll});
            }
        });

        var param="param={";
        param = getJsonDataNotEmpty(param,"type","1");
        param += "}";
        suixun.ajax(serverUrl+'/schoolManage/queryRegion.json',param,"get",function(data){
            if(data.code == 200){
                for(var i = 0 ;i < data.info.length;i++ ){
                    addresData[i] = {value:data.info[i].province,type:"1",province:data.info[i].province,city:""};
                }
                addresDataOth = addresData;
                svar.setState({addresData:addresData,addresDataOth:addresDataOth});
            }
        });
        //绑定回车时间
        $(document).keypress(function(e) {
            var eCode = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
            if (eCode == 13){
                if($(".enterEvent1").is(":focus")){
                    svar.onClickQueryTable();
                }else if($(".enterEvent2").is(":focus")){
                    svar.onClickQueryHistogram();
                }
            }
        });
    },
    /**
     * 查询学校数据
     */
    selectSchoolData: function () {
        suixun.showLoding();//显示加载中
        var svar = this;
        suixun.ajax(serverUrl+'/schoolManage/querySchool.json','',"get",function(data){
            suixun.hideLoding();//隐藏加载中
            if(data.code == 200 ){
                for(var i=0;i<data.info.length;i++){
                    var obj=data.info[i];
                    schoolDataList[i] = {key:i,id:obj.id,schoolname:obj.schoolname};
                }
                schoolDataAll = schoolDataList;
                svar.setState({schoolDataList:schoolDataList,schoolDataAll:schoolDataAll});
            }else{
                svar.setState({schoolDataList:schoolDataList,schoolDataAll:schoolDataAll});
            }
        });
    },
    /**
     * 查询地址
     */
    selectAddress:function () {
        var svar = this;
        var param="param={";
        param = getJsonDataNotEmpty(param,"type","1");
        param += "}";
        suixun.ajax(serverUrl+'/schoolManage/queryRegion.json',param,"get",function(data){
            if(data.code == 200){
                for(var i = 0 ;i < data.info.length;i++ ){
                    addresData[i] = {value:data.info[i].province,type:"1",province:data.info[i].province,city:""};
                }
                addresDataOth = addresData;
                svar.setState({addresData:addresData,addresDataOth:addresDataOth});
            }
        });
    },
    /**
     * 绘画柱状图
     * @param maxNumber
     */
    setOption: function (maxNumber) {
        var myChart = myChart = echarts.init(document.getElementById('dendrogram-centent'));
        if(maxNumber == 1 || maxNumber == 0){
            maxNumber = 1;
        }else if(maxNumber == 2){
            maxNumber = 2;
        }else if(maxNumber == 3){
            maxNumber = 3;
        }else if(maxNumber == 4){
            maxNumber = 4;
        }else{
            maxNumber = 5;
        }
        option = {
            tooltip : {
                trigger: 'item',// axis
                showDelay : 0, // 显示延迟，添加显示延迟可以避免频繁切换，单位ms
                axisPointer : {// 坐标轴指示器，坐标轴触发有效
                    type : 'line',// 默认为直线，可选为：'line' | 'shadow'
                }
            },
            calculable : false,
            xAxis : [
                {
                    name:'日期',
                    type : 'category',
                    data : this.state.xAxisData,
                    splitLine:{
                        show:false
                    }
                }
            ],

            yAxis : [
                {
                    name:'台',
                    type : 'value',
                    splitNumber: maxNumber,
                    boundaryGap: false,
                    axisLabel : {
                        formatter: function (value, index) {
                            return ''+value.toFixed(0)+'';
                        }
                    },
                    splitLine:{
                        show:false//横起的线
                    },
                    axisLine:{
                        onZero:true,
                    }

                }
            ],
            series : [
                {
                    name:'智能学生证激活量',
                    type:'bar',
                    barWidth: 20,
                    itemStyle:{
                        normal:{color:'#1ec94a'}
                    },
                    data:this.state.intelligentData
                },
                {
                    name:'2.4G考勤卡激活量',
                    type:'bar',
                    barWidth: 20,
                    itemStyle:{
                        normal:{color:'#faba00'}
                    },
                    data:this.state.cardData
                },
                {
                    name:'缴费量',
                    type:'bar',
                    barWidth: 20,
                    itemStyle:{
                        normal:{color:'#01b4ee'}
                    },
                    data:this.state.payPraceData
                },
                {
                    name:'13.56考勤卡激活量',
                    type:'bar',
                    barWidth: 20,
                    itemStyle:{
                        normal:{color:'#347fff'}
                    },
                    data:this.state.ThiPointFXData
                }
            ]
        };
        myChart.setOption(option);
    },
    /**
     * 统计分析-数据总览-查询
     */
    onClickQueryTable: function () {
        var svar = this;
        var querInput = $("#query_school_1").val(),query01 = $(".school-or-classTeacher").html();
        if(querInput == "" && query01 == "按地区"){
            return;
        }
        var param="param={";
        if(query01 == "学校"){
            param = getJsonDataNotEmpty(param,"schoolname",'"'+querInput+'"');
            pageView.schoolTableView = false;
            pageView.clsaaTableView = true;
            if(querInput == ""){
                suixun.alert("学校不能为空！");
                return;
            }
        }else if(query01 == "班主任"){
            if(querInput.length > 0){
                if(querInput.length != 11 || !/^[1-9]\d*$/.test(querInput)){
                    suixun.alert("班主任手机号格式错误!");
                    return;
                }
            }
            param = getJsonDataNotEmpty(param,"peopletel",'"'+querInput+'"');
            pageView.schoolTableView = false;
            pageView.clsaaTableView = false;
        }else{//按地区查询的时候需要查询学校的表单
            var address = querInput.split("-");
            if(address.length == 1){
                param = getJsonDataNotEmpty(param,"province",'"'+address[0]+'"');
            }else if(address.length == 2){
                param = getJsonDataNotEmpty(param,"province",'"'+address[0]+'"');
                param = getJsonDataNotEmpty(param,"city",'"'+address[1]+'"');
            }else{
                param = getJsonDataNotEmpty(param,"province",'"'+address[0]+'"');
                param = getJsonDataNotEmpty(param,"city",'"'+address[1]+'"');
                param = getJsonDataNotEmpty(param,"town",'"'+address[2]+'"');
            }
            if(($("#startdate").val() && $("#enddate").val()) && new Date($("#startdate").val()) > new Date($("#enddate").val())){
                suixun.alert('开始日期不能大于结束日期！');
                return;
            }
            if($("#startdate").val()){
                param = getJsonDataNotEmpty(param,"starttime",'"'+$("#startdate").val()+'"');
            }
            if($("#enddate").val()){
                param = getJsonDataNotEmpty(param,"endtime",'"'+$("#enddate").val()+'"');
            }
            this.querySchoolList(param);//查询学校的数据
            pageView.clsaaTableView = false;
        }
        param = getJsonDataNotEmpty(param,"startdate",'"'+$("#startdate").val()+'"');
        param = getJsonDataNotEmpty(param,"enddate",'"'+$("#enddate").val()+'"');
        param += "}";
        suixun.showLoding();//显示加载中
        if(query01 == "学校"){
            schoolDetailsTableData = [];
            console.log(param);
            suixun.ajax(serverUrl+'/workspaceManager/countBySchool.json',param.replace('startdate','starttime').replace('enddate','endtime'),"get",function(data){
                suixun.hideLoding();//隐藏加载中
                if(data.code == 200 ){
                    if(data.info != null){
                        for(var i=0;i<data.info.length;i++){
                            var obj=data.info[i];
                            schoolDetailsTableData[i] = {cardsendcounts:obj.cardsendcounts,cardvalidcounts:obj.cardvalidcounts,devicevalidcounts:obj.devicevalidcounts,devicepaycounts:obj.devicepaycounts,schoolname:obj.schoolname,classname:obj.classname,teachertel:obj.teachertel,teachername:obj.teachername};
                        }
                        svar.setState({schoolDetailsTableData:schoolDetailsTableData});
                    }else{
                        svar.setState({schoolDetailsTableData:schoolDetailsTableData});
                    }
                }else{
                    suixun.alert(data.msg);
                }
            });
        }
        this.getStatDeviceList(param);//获取数据总览
    },
    /**
     * 获取数据总览
     * @param param
     */
    getStatDeviceList: function (param) {
        tableData=[];
        var svar = this;
        suixun.ajax(serverUrl+'/workspaceManager/statDeviceList.json',param,"get",function(data){
            suixun.hideLoding();//隐藏加载中
            if(data.code == 200){
                if(data.info != null){
                    for(var i=0;i<data.info.length;i++){
                        var obj=data.info[i];
                        tableData[i] = {devicetype:obj.devicetype,devicetypename:obj.devicetypename,devicecounts:obj.devicecounts,validcounts:obj.validcounts,paycounts:obj.paycounts,onlinecounts:obj.onlinecounts,offlinecounts:obj.offlinecounts};
                    }
                    svar.setState({tableData:tableData,pageView:pageView});
                }else{
                    svar.setState({tableData:tableData,pageView:pageView});
                }

            }
        });
    },
    /**
     *统计分析-一数据总览-点击列表
     */
    onClickTable: function (e) {
        $("#query_school_1").val($(e.target).html());
        this.onClickQueryTable();
    },
    /**
     *统计分析-一周趋势-点击列表
     */
    onClickBar: function (e) {
        $("#query_school_2").val($(e.target).html());
        this.onClickQueryHistogram();
    },
    /**
     * 统计分析-一周趋势-查询
     */
    onClickQueryHistogram: function () {
        var param="param={";
        if($(".school-or-address").html() == "按学校"){
            param = getJsonDataNotEmpty(param,"schoolname",$("#query_school_2").val());
        }else{
            var address = $("#query_school_2").val().split("-");
            if(address.length == 1){
                param = getJsonDataNotEmpty(param,"province",'"'+address[0]+'"');
            }else if(address.length == 2){
                param = getJsonDataNotEmpty(param,"province",'"'+address[0]+'"');
                param = getJsonDataNotEmpty(param,"city",'"'+address[1]+'"');
            }else{
                param = getJsonDataNotEmpty(param,"province",'"'+address[0]+'"');
                param = getJsonDataNotEmpty(param,"city",'"'+address[1]+'"');
                param = getJsonDataNotEmpty(param,"town",'"'+address[2]+'"');
            }
        }
        param += "}";
        intelligentData=[];
        xAxisData=[];
        cardData=[];
        payPraceData=[];
        suixun.showLoding();//显示加载中
        var svar = this;
        suixun.ajax(serverUrl+'/workspaceManager/statDeviceListByDate.json',param,"get",function(data){
            var i=0,maxNumber = 0;
            suixun.hideLoding();//隐藏加载中
            if(data.code == 200){
                for(var key in data.info[0]){
                    if(data.info[0][key].validcounts!=null && data.info[0][key].validcounts > maxNumber){
                        maxNumber = data.info[0][key].validcounts;
                    }
                    intelligentData[i]=data.info[0][key].validcounts!=null?data.info[0][key].validcounts:0;
                    xAxisData[i++]=key;
                }
                i=0;
                for(var key in data.info[1]){
                    if(data.info[1][key].validcounts!=null && data.info[1][key].validcounts > maxNumber){
                        maxNumber = data.info[1][key].validcounts;
                    }
                    cardData[i++]=data.info[1][key].validcounts!=null?data.info[1][key].validcounts:0;
                }
                i=0;
                for(var key in data.info[2]){
                    if(data.info[2][key].paycounts!=null && data.info[2][key].paycounts > maxNumber){
                        maxNumber = data.info[2][key].paycounts;
                    }
                    payPraceData[i++]=data.info[2][key].paycounts!=null?data.info[2][key].paycounts:0;
                }
                i=0;
                for(var key in data.info[3]){
                    if(data.info[3][key].validcounts!=null && data.info[3][key].validcounts > maxNumber){
                        maxNumber = data.info[3][key].validcounts;
                    }
                    ThiPointFXData[i++]=data.info[3][key].validcounts!=null?data.info[3][key].validcounts:0;
                }
                svar.setState({cardData:cardData,intelligentData:intelligentData,payPraceData:payPraceData,xAxisData:xAxisData,ThiPointFXData:ThiPointFXData});
                svar.setOption(maxNumber);
            }
        });
    },
    /**
     * 改变弹出层学校输入框
     * @param e
     */
    onChangSchoolInput: function (e) {
        if($(e.target).attr("data-select") == "1"){
            var value = $(".school-or-classTeacher").html();
            if(value == "班主任" || value == "按地区"){
                return;
            }
        }else{
            if($(".school-or-address").html() == "按地区" ){
                return;
            }
        }
        var val = $(e.target).val();
        if(val != ""){
            this.schoolArray(val,$(e.target).attr("data-list"));
        }else{
            $("."+$(e.target).attr("data-list")+"").hide();
        }
    },
    /**
     * 排序
     * @param val
     * @param cls
     */
    schoolArray: function (val,cls) {
        schoolDataList = [];
        for(var i = 0;i < schoolDataAll.length;i++){
            if((schoolDataAll[i].schoolname).indexOf(val) >= 0){
                schoolDataList.push({schoolname:schoolDataAll[i].schoolname});
            }
        }
        if(schoolDataList.length == 0){
            $("."+cls+"").hide();
        }else{
            $("."+cls+"").show();
            this.setState({schoolDataList:schoolDataList});
        }
    },
    //点击学校输入框
    onClickSchool: function (e) {
        if($(e.target).attr("data-select") == "1"){
            if($(".school-or-classTeacher").html() == "班主任"){
                return;
            }else if($(".school-or-classTeacher").html() == "按地区"){
                $(".addressesOne").show();
                $(".provinceOth").addClass(" addresses-select").siblings().removeClass(" addresses-select");
                var addres = $("#query_school_1").val(),addreses = addres.split("-");
                if(addreses[0] != "" && addreses.length == 1){
                    $(".cityOth").addClass("cli");
                    $(".provinceOth").addClass("cli");
                    $(".areaOth").removeClass(" cli");
                }else if(addreses.length == 2 || addreses.length == 3){
                    $(".cityOth").addClass("cli");
                    $(".provinceOth").addClass("cli");
                    $(".areaOth").addClass(" cli");
                }else{
                    $(".cityOth").removeClass("cli");
                    $(".areaOth").removeClass(" cli");
                }
                this.selectAddress();
                return;
            }
        }else{
            if($(".school-or-address").html() == "按地区"){
                $(".addressesTwo").show();
                $(".province").addClass(" addresses-select").siblings().removeClass(" addresses-select");
                var addres = $("#query_school_2").val(),addreses = addres.split("-");
                if(addreses[0] != "" && addreses.length == 1){
                    $(".city").addClass("cli");
                    $(".province").addClass("cli");
                    $(".area").removeClass(" cli");
                }else if(addreses.length == 2 || addreses.length == 3){
                    $(".city").addClass("cli");
                    $(".province").addClass("cli");
                    $(".area").addClass(" cli");
                }else{
                    $(".city").removeClass("cli");
                    $(".area").removeClass(" cli");
                }
                this.selectAddress();
                return;
            }
        }
        var val = $(e.target).val();
        this.schoolArray(val,$(e.target).attr("data-list"));
    },
    /**
     * 一周趋势
     * 查询地址
     * @param e
     */
    queryAddress:function (e) {
        var type = $(e.target).attr("data-type"),
            province = $(e.target).attr("data-province"),
            city = $(e.target).attr("data-city");
        if(type == "1"){
            $("#query_school_2").val(province);
            $(".province").removeClass(" addresses-select");
            $(".province").addClass(" cli");
            $(".city").addClass(" addresses-select");
            $(".area").removeClass(" cli");
        }else  if(type == "2"){
            $("#query_school_2").val(province+"-"+city);
            $(".city").removeClass(" addresses-select");
            $(".city").addClass(" cli");
            $(".area").addClass(" addresses-select");
        }else {
            $("#query_school_2").val(province + "-" + city + "-" + e.target.innerHTML);
            $(".addressesTwo").hide();
            return;
        }
        type = parseInt(type)+1;
        var param="param={";
        param = getJsonDataNotEmpty(param,"type",'"'+type+'"');
        param = getJsonDataNotEmpty(param,"province",'"'+province+'"');
        param = getJsonDataNotEmpty(param,"city",'"'+city+'"');
        param += "}";
        var svar = this;
        suixun.ajax(serverUrl+'/schoolManage/queryRegion.json',param,"get",function(data){
            addresData = [];
            if(data.code == 200){
                if(type == "1"){
                    for(var i = 0 ;i < data.info.length;i++ ){
                        addresData[i] = {value:data.info[i].province,type:"1",province:data.info[i].province,city:""};
                    }
                }else if(type == "2"){
                    for(var i = 0 ;i < data.info.length;i++ ){
                        addresData[i] = {value:data.info[i].city,type:"2",city:data.info[i].city,province:province};
                    }
                }else{
                    for(var i = 0 ;i < data.info.length;i++ ){
                        addresData[i] = {value:data.info[i].town,type:"3",city:city,province:province};
                    }
                }
            }
            svar.setState({addresData:addresData});
        });
    },
    /**
     * 一周趋势
     * 点击城市
     * @param e
     */
    onClickCity: function (e) {
        var type = $(e.target).attr("data-type"),addres = $("#query_school_2").val(),addreses = addres.split("-"),province = "",city = "";
        if(type == "1"){
            province = "";
            city = "";
        }else if(type == "2"){
            if(addreses[0] != ""){
                province = addreses[0];
                city = "";
            }else{
                return;
            }
        }else if(type == "3"){
            if(addreses[0] != "" && addreses.length > 1){
                province = addreses[0];
                city = addreses[1];
            }else{
                return;
            }
        }else if(type == "4"){
            $(".addressesTwo").hide();
            return;
        }
        $(e.target).addClass(" addresses-select").siblings().removeClass(" addresses-select");
        if(addreses[0] != "" && addreses.length == 1){
            $(".city").addClass("cli");
            $(".province").addClass("cli");
            $(".area").removeClass(" cli");
        }else if(addreses.length == 2 || addreses.length == 3){
            $(".city").addClass("cli");
            $(".province").addClass("cli");
            $(".area").addClass(" cli");
        }else{
            $(".city").removeClass("cli");
            $(".area").removeClass(" cli");
        }
        var param="param={";
        param = getJsonDataNotEmpty(param,"type",'"'+type+'"');
        param = getJsonDataNotEmpty(param,"province",'"'+province+'"');
        param = getJsonDataNotEmpty(param,"city",'"'+city+'"');
        param += "}";
        var svar = this;
        suixun.ajax(serverUrl+'/schoolManage/queryRegion.json',param,"get",function(data){
            addresData = [];
            if(data.code == 200){
                if(type == "1"){
                    for(var i = 0 ;i < data.info.length;i++ ){
                        addresData[i] = {value:data.info[i].province,type:"1",province:data.info[i].province,city:""};
                    }
                }else if(type == "2"){
                    for(var i = 0 ;i < data.info.length;i++ ){
                        addresData[i] = {value:data.info[i].city,type:"2",city:data.info[i].city,province:province};
                    }
                }else{
                    for(var i = 0 ;i < data.info.length;i++ ){
                        addresData[i] = {value:data.info[i].town,type:"3",city:city,province:province};
                    }
                }
            }
            svar.setState({addresData:addresData});
        });
    },
    /**
     * 统计分析
     * 点击城市
     * @param e
     */
    onClickCityOth: function (e) {
        var type = $(e.target).attr("data-type"),addres = $("#query_school_1").val(),addreses = addres.split("-"),province = "",city = "";
        if(type == "1"){
            province = "";
            city = "";
        }else if(type == "2"){
            if(addreses[0] != ""){
                province = addreses[0];
                city = "";
            }else{
                return;
            }
        }else if(type == "3"){
            if(addreses[0] != "" && addreses.length > 1){
                province = addreses[0];
                city = addreses[1];
            }else{
                return;
            }
        }else if(type == "4"){
            $(".addressesOne").hide();
            return;
        }
        $(e.target).addClass(" addresses-select").siblings().removeClass(" addresses-select");
        if(addreses[0] != "" && addreses.length == 1){
            $(".cityOth").addClass("cli");
            $(".provinceOth").addClass("cli");
            $(".areaOth").removeClass(" cli");
        }else if(addreses.length == 2 || addreses.length == 3){
            $(".cityOth").addClass("cli");
            $(".provinceOth").addClass("cli");
            $(".areaOth").addClass(" cli");
        }else{
            $(".cityOth").removeClass("cli");
            $(".areaOth").removeClass(" cli");
        }
        var param="param={";
        param = getJsonDataNotEmpty(param,"type",'"'+type+'"');
        param = getJsonDataNotEmpty(param,"province",'"'+province+'"');
        param = getJsonDataNotEmpty(param,"city",'"'+city+'"');
        param += "}";
        var svar = this;
        suixun.ajax(serverUrl+'/schoolManage/queryRegion.json',param,"get",function(data){
            addresDataOth = [];
            if(data.code == 200){
                if(type == "1"){
                    for(var i = 0 ;i < data.info.length;i++ ){
                        addresDataOth[i] = {value:data.info[i].province,type:"1",province:data.info[i].province,city:""};
                    }
                }else if(type == "2"){
                    for(var i = 0 ;i < data.info.length;i++ ){
                        addresDataOth[i] = {value:data.info[i].city,type:"2",city:data.info[i].city,province:province};
                    }
                }else{
                    for(var i = 0 ;i < data.info.length;i++ ){
                        addresDataOth[i] = {value:data.info[i].town,type:"3",city:city,province:province};
                    }
                }
            }
            svar.setState({addresDataOth:addresDataOth});
        });
    },
    /**
     * 统计分析
     * 查询地址
     * @param e
     */
    queryAddressOth:function (e) {
        var type = $(e.target).attr("data-type"),
            province = $(e.target).attr("data-province"),
            city = $(e.target).attr("data-city");
        if(type == "1"){
            $("#query_school_1").val(province);
            $(".provinceOth").removeClass(" addresses-select");
            $(".provinceOth").addClass(" cli");
            $(".cityOth").addClass(" addresses-select");
            $(".areaOth").removeClass(" cli");
        }else  if(type == "2"){
            $("#query_school_1").val(province+"-"+city);
            $(".cityOth").removeClass(" addresses-select");
            $(".cityOth").addClass(" cli");
            $(".areaOth").addClass(" addresses-select");
        }else {
            $("#query_school_1").val(province + "-" + city + "-" + e.target.innerHTML);
            $(".addressesOne").hide();
            return;
        }
        type = parseInt(type)+1;
        var param="param={";
        param = getJsonDataNotEmpty(param,"type",'"'+type+'"');
        param = getJsonDataNotEmpty(param,"province",'"'+province+'"');
        param = getJsonDataNotEmpty(param,"city",'"'+city+'"');
        param += "}";
        var svar = this;
        suixun.ajax(serverUrl+'/schoolManage/queryRegion.json',param,"get",function(data){
            addresDataOth = [];
            if(data.code == 200){
                if(type == "1"){
                    for(var i = 0 ;i < data.info.length;i++ ){
                        addresDataOth[i] = {value:data.info[i].province,type:"1",province:data.info[i].province,city:""};
                    }
                }else if(type == "2"){
                    for(var i = 0 ;i < data.info.length;i++ ){
                        addresDataOth[i] = {value:data.info[i].city,type:"2",city:data.info[i].city,province:province};
                    }
                }else{
                    for(var i = 0 ;i < data.info.length;i++ ){
                        addresDataOth[i] = {value:data.info[i].town,type:"3",city:city,province:province};
                    }
                }
            }
            svar.setState({addresData:addresDataOth});
        });
    },
    /**
     * 导出excel
     * @returns {XML}
     */
    inportExcel:function () {
        suixun.confirm_noTit("是否确定导出Excel？",function (data) {
            if(data){
                var querInput = $("#query_school_1").val();
                if(querInput == ""){
                    setTimeout(function () {
                        suixun.alert("搜索框不能为空！");
                    },100);
                }else{
                    var param="param={";
                    var address = querInput.split("-");
                    if(address.length == 1){
                        param = getJsonDataNotEmpty(param,"province",'"'+address[0]+'"');
                    }else if(address.length == 2){
                        param = getJsonDataNotEmpty(param,"province",'"'+address[0]+'"');
                        param = getJsonDataNotEmpty(param,"city",'"'+address[1]+'"');
                    }else{
                        param = getJsonDataNotEmpty(param,"province",'"'+address[0]+'"');
                        param = getJsonDataNotEmpty(param,"city",'"'+address[1]+'"');
                        param = getJsonDataNotEmpty(param,"town",'"'+address[2]+'"');
                    }
                    if(($("#startdate").val() && $("#enddate").val()) && new Date($("#startdate").val()) > new Date($("#enddate").val())){
                        setTimeout(function () {
                            suixun.alert('开始日期不能大于结束日期！');
                        },1);
                        return;
                    }
                    if($("#startdate").val()){
                        param = getJsonDataNotEmpty(param,"starttime",'"'+$("#startdate").val()+'"');
                    }
                    if($("#enddate").val()){
                        param = getJsonDataNotEmpty(param,"endtime",'"'+$("#enddate").val()+'"');
                    }
                    param += "}";
                    window.location.href = serverUrl+'/workspaceManager/export_countByRegion.json?'+param;
                }
            }
        });
    },
    /**
     * 查询学校
     * @param info
     */
    onClickSelectSchool:function (info) {
        var svar = this;
        $("#deviceInfo").val(info);//设置查询学校的信息
        if(info[2] != null && info[2] != ""){
            $(".promotionTime").html(info[2]);
        }else{
            $(".promotionTime").html("无");
        }
        $(".schoolName").html(info[0]);//设置学校
        $(".select-title").html("默认排序");
        pageView.schoolBarView = true;
        this.setState({pageView:pageView});
        this.queryCountBySchool("");//查询学校班级详情

    },
    /**
     * 学校详情-点击排序
     * @param value 值
     * @param e 选择的对象
     */
    onClickSort: function (value,e) {
        $(".select-title").html(e.target.innerHTML);
        this.queryCountBySchool(value);//查询学校班级详情
    },
    /**
     * 更具学校查询学校班级详情
     * @param sort
     */
    queryCountBySchool: function (sort) {
        suixun.showLoding();//显示加载中
        var svar = this;
        var param="param={";
        param = getJsonDataNotEmpty(param,"schoolname",'"'+$(".schoolName").html()+'"');
        param = getJsonDataNotEmpty(param,"sortstatus",sort+'');
        param += "}";
        schoolDetailsTableData = [];
        suixun.ajax(serverUrl+'/workspaceManager/countBySchool.json',param,"get",function(data){
            suixun.hideLoding();//隐藏加载中
            if(data.code == 200 ){
                if(data.info != null){
                    for(var i=0;i<data.info.length;i++){
                        var obj=data.info[i];
                        schoolDetailsTableData[i] = {cardsendcounts:obj.cardsendcounts,cardvalidcounts:obj.cardvalidcounts,devicevalidcounts:obj.devicevalidcounts,devicepaycounts:obj.devicepaycounts,schoolname:obj.schoolname,classname:obj.classname,teachertel:obj.teachertel,teachername:obj.teachername};
                    }
                    svar.setState({schoolDetailsTableData:schoolDetailsTableData});
                }else{
                    svar.setState({schoolDetailsTableData:schoolDetailsTableData});
                }
            }else{
                suixun.alert(data.msg);
            }
        });
    },
    /**
     * 更具地区查询学校列表
     * @param param
     */
    querySchoolList: function (param) {
        var svar = this;
        param += "}";
        schoolTableData = [];
        suixun.showLoding();//显示加载中
        suixun.ajax(serverUrl+'/workspaceManager/countByRegion.json',param,"get",function(data){
            suixun.hideLoding();//隐藏加载中
            if(data.code == 200){
                // for(var i=0;i<data.info.length;i++){
                //     var obj=data.info[i];
                //     schoolTableData[i] = {devicetypename:obj.devicetypename,cardsendcounts:obj.cardsendcounts,cardvalidcounts:obj.cardvalidcounts,devicesendcounts:obj.devicesendcounts,devicevalidcounts:obj.devicevalidcounts,devicepaycounts:obj.devicepaycounts,schoolname:obj.schoolname,discounttime:obj.discounttime};
                // }
                pageView.schoolTableView = true;
                svar.setState({schoolTableData:data.info==null?[]:data.info,pageView:pageView});
            }
        });
    },
    /**
     * 点击返回
     */
    onClickReturn: function () {
        pageView.schoolBarView = false;
        this.setState({pageView:pageView});
    },
    render: function () {
        {
            var svar = this;
            var tableMethodArray = [this.onClickSelectSchool];
            var Tabels = this.state.tableData.map(function (data) {
                return (
                    <Table key={data.devicetype} devicetypename={data.devicetypename} devicecounts={data.devicecounts} validcounts={data.validcounts} paycounts={data.paycounts} onlinecounts={data.onlinecounts} offlinecounts={data.offlinecounts} />
                )
            });
            var SchoolTables  = this.state.schoolTableData.map(function (data,index) {
                return (
                    <SchoolTable key={index} listNumber={index} onClickSelectSchool={tableMethodArray[0].bind(svar,[data.schoolname,data.devicetypename,data.discounttime])} trData={data} />
                )
            });
            var SchoolDetailsTables  = this.state.schoolDetailsTableData.map(function (data,index) {
                return (
                    <SchoolDetailsTable key={index} listNumber={index} cardsendcounts={data.cardsendcounts} cardvalidcounts={data.cardvalidcounts} devicevalidcounts={data.devicevalidcounts} devicepaycounts={data.devicepaycounts} schoolname={data.schoolname} classname={data.classname} teachertel={data.teachertel} teachername={data.teachername} />
                )
            });
        }
        return (
            <div className="tableManage-body">
                <div className="statistical-analysis" style={{display:pageView.schoolBarView==false?"block":"none"}}>
                    <div className="statistical-analysis-top">
                        <div className="statistical-analysis-top-left">
                            <div className="statistical-analysis-top-left-title">统计分析</div>
                            <div className="statistical-analysis-top-left-text">
                                <img src="../img/icon/annotations.png" />
                                <div>这里是注释。</div>
                            </div>
                        </div>
                        <div className="header-right" onClick={this.inportExcel}>
                            <div className="export">
                                <span className="export-img">
                                    <img src="../img/icon/export.png" />
                                </span>
                                <span className="export-text">导出excel</span>
                            </div>
                        </div>
                    </div>
                    <div className="statistical-aanalysis-query">
                        <div className="header-right-select droup-select header-right-select-one">
                            <div className="school-or-parent school-or-classTeacher">按地区</div>
                            <span className="lower-right-corner"/>
                            <div className="drop-down schoolClassTeacher" >
                                <span className="select-value " >学校</span>
                                <span className="select-value select-value-top" >班主任</span>
                                <span className="select-value select-value-top" >按地区</span>
                            </div>
                        </div>
                        <div className="header-right-query">
                            <div className="header-right-query-input">
                                <input className="queryVal-select enterEvent1" type="text" onChange={this.onChangSchoolInput} onClick={this.onClickSchool} data-select="1"  data-list="querySchoolTable" maxLength="50" name="query_school_1" id="query_school_1" placeholder="请选择省市区筛选"/>
                            </div>
                            <div className="header-right-query-img" data-value="1" onClick={this.onClickQueryTable}></div>
                            <div className="schoolList querySchoolTable" data-inputId="query_school_1">
                                {
                                    schoolDataList.map(function (data) {
                                        return (
                                            <span className="schoolList-value" onClick={svar.onClickTable}>{data.schoolname}</span>
                                        )
                                    })
                                }
                            </div>
                            <div className="addresses addressesOne" >
                                <div className="addresses-title">
                                    <ul className="city-tab">
                                        <li className="city-tab-list provinceOth addresses-select cli" onClick={this.onClickCityOth} data-type="1">省 份</li>
                                        <li className="city-tab-list cityOth" onClick={this.onClickCityOth} data-type="2">城 市</li>
                                        <li className="city-tab-list areaOth" onClick={this.onClickCityOth} data-type="3">区（县）</li>
                                        <li className="city-tab-list cityOk" onClick={this.onClickCityOth} data-type="4">确定</li>
                                    </ul>
                                </div>
                                <div className="addresses-content">
                                    <ul className="addresses-content-item">
                                        {
                                            addresDataOth.map(function(data,index){
                                                return(
                                                    <li  onClick={svar.queryAddressOth} data-type={data.type} data-province={data.province} data-city={data.city} title={data.value} className="addresses-item-center text-sub">{data.value}</li>
                                                )
                                            })
                                        }
                                    </ul>
                                </div>
                            </div>
                        </div>
                        <div className="checkTime">
                            <span className="checkTime-title">日期</span>
                            <span className="popAddMessage-body-input-content">
                                <input className="frequencyTime beginTime" type="text" onClick={this.onClickTimer} placeholder="开始日期"  readonly name="startdate" id="startdate"/>
                            </span>
                            <span className="timeMiddle"/>
                            <span className="popAddMessage-body-input-content" >
                                <input className="frequencyTime endTime" type="text"  onClick={this.onClickTimer} placeholder="结束日期"  readonly  name="enddate" id="enddate"/>
                            </span>
                            <span className="header-right-query-button" data-value="1" onClick={this.onClickQueryTable}>搜索</span>
                        </div>
                    </div>
                    <div className="statistical-analysis-top">
                        <div className="statistical-analysis-top-left">
                            <div className="statistical-analysis-top-left-title">数据总览</div>
                            <div className="statistical-analysis-top-left-text">
                                <img src="../img/icon/annotations.png" />
                                <div>这里是注释。</div>
                            </div>
                        </div>
                        <div className="statistical-analysis-top-right">数量单位：台</div>
                    </div>
                    <div className="statistical-analysis-content">
                        <table>
                            <thead>
                                <th/>
                                <th>设备总量</th>
                                <th>激活量</th>
                                <th>有效设备量</th>
                            </thead>
                            <tbody>
                                {this.state.tableData==""?'':Tabels}
                            </tbody>
                        </table>
                        {this.state.tableData==""?<div className="tableNoData">{tableNoDataCount}</div>:''}
                    </div>
                </div>
                {
                    /**
                     * <div className="statistical-analysis" style={{display:pageView.schoolBarView==false?(pageView.schoolTableView==false?(pageView.clsaaTableView==false?"block":"none"):"none"):"none"}}>
                     */
                }
                <div className="statistical-analysis" style={{display:"none"}}>
                    <div className="statistical-analysis-top">
                        <div className="statistical-analysis-top-left">
                            <div className="statistical-analysis-top-left-title">一周趋势</div>
                            <div className="statistical-analysis-top-left-text">
                                <img src="../img/icon/annotations.png" />
                                <div>这里是注释。</div>
                            </div>
                        </div>
                    </div>
                    <div className="statistical-analysis-content dendrogram">
                        <div className="dendrogram-query">
                            <div className="dendrogram-query-left">
                                <div className="header-right-select droup-select header-right-select-two">
                                    <div className="school-or-parent school-or-address">按学校</div>
                                    <span className="lower-right-corner"/>
                                    <div className="drop-down weekTrend" >
                                        <span className="select-value">按学校</span>
                                        <span className="select-value select-value-top" >按地区</span>
                                    </div>
                                </div>
                                <div className="dendrogram-query-left-query">
                                    <div className="dendrogram-query-left-query-input">
                                        <input className="queryVal enterEvent2" type="text" onChange={this.onChangSchoolInput} onClick={this.onClickSchool} data-select="2" data-list="querySchoolHistogram"  maxLength="50" name="query_school_2" id="query_school_2" placeholder="请输入学校筛选"/>
                                    </div>
                                    <div className="dendrogram-query-left-query-img"  data-value="2" onClick={this.onClickQueryHistogram}></div>
                                    <div className="schoolList querySchoolHistogram" data-inputId="query_school_2">
                                        {
                                            schoolDataList.map(function (data) {
                                                return (
                                                    <span className="schoolList-value" onClick={svar.onClickBar}>{data.schoolname}</span>
                                                )
                                            })
                                        }
                                    </div>
                                    <div className="addresses addressesTwo" >
                                        <div className="addresses-title">
                                            <ul className="city-tab">
                                                <li className="city-tab-list province addresses-select cli" onClick={this.onClickCity} data-type="1">省 份</li>
                                                <li className="city-tab-list city" onClick={this.onClickCity} data-type="2">城 市</li>
                                                <li className="city-tab-list area" onClick={this.onClickCity} data-type="3">区（县）</li>
                                                <li className="city-tab-list cityOk" onClick={this.onClickCity} data-type="4">确定</li>
                                            </ul>
                                        </div>
                                        <div className="addresses-content">
                                            <ul className="addresses-content-item">
                                                {
                                                    addresData.map(function(data,index){
                                                        return(
                                                            <li onClick={svar.queryAddress} data-type={data.type} data-province={data.province} data-city={data.city} title={data.value} className="addresses-item-center text-sub">{data.value}</li>
                                                        )
                                                    })
                                                }
                                            </ul>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div className="dendrogram-query-right">
                                <div><span style={{background:"#01b4ee"}}/>缴费量</div>
                                <div style={{marginRight:"30px"}}><span style={{background:"#faba00"}}/>2.4G考勤卡激活量</div>
                                <div style={{marginRight:"30px"}}><span style={{background:"#347fff"}}/>13.56考勤卡激活量</div>
                                <div style={{marginRight:"30px"}}><span style={{background:"#1ec94a"}}/>智能学生证激活量</div>
                            </div>
                        </div>
                        <div className="dendrogram-centent" id="dendrogram-centent">
                        </div>
                    </div>
                </div>
                {
                    /**
                     *学校的表单
                     */
                }
                <div style={{display:pageView.schoolBarView==false?(pageView.schoolTableView==true?"block":"none"):"none"}}>
                    <div className="parentsInfo tableInfo">
                        <div className="parentsInfo-data tableInfo-data">
                            <div className="parentsInfo-data-table tableInfo-data-table" >
                                <table className="head-body head-body">
                                    <thead>
                                        <th style={{width: '5%'}}>序号</th>
                                        <th style={{width: '10%'}}>省市区</th>
                                        <th style={{width: '12%'}}>学校名称</th>
                                        <th style={{width: '12%'}}>促销时间</th>
                                        <th style={{width: '8%'}}>考勤卡类型</th>
                                        <th style={{width: '9%'}}>考勤卡发放量</th>
                                        <th style={{width: '9%'}}>考勤卡激活量</th>
                                        <th style={{width: '9%'}}>学生证发放量</th>
                                        <th style={{width: '9%'}}>学生证激活量</th>
                                        <th style={{width: '9%'}}>学生证缴费量</th>
                                        <th style={{width: '8%'}}>操作</th>
                                    </thead>
                                    <tbody>
                                    {this.state.schoolTableData==""?'':SchoolTables}
                                    </tbody>
                                </table>
                                {this.state.schoolTableData==""?<div className="tableNoData">{tableNoDataCount}</div>:''}
                            </div>
                        </div>
                    </div>
                </div>
                <div style={{display:pageView.schoolBarView==false?(pageView.clsaaTableView==true?"block":"none"):"none"}}>
                    <div className="parentsInfo tableInfo">
                        <div className="parentsInfo-data tableInfo-data">
                            <div className="parentsInfo-data-table tableInfo-data-table" >
                                <table className="head-body head-body">
                                    <thead>
                                    <th style={{width: '9%'}}>序号</th>
                                    <th style={{width: '15%'}}>班级</th>
                                    <th style={{width: '15%'}}>手机号</th>
                                    <th style={{width: '13%'}}>老师姓名</th>
                                    <th style={{width: '12%'}}>考勤卡发放量</th>
                                    <th style={{width: '12%'}}>考勤卡激活量</th>
                                    <th style={{width: '12%'}}>学生证激活量</th>
                                    <th style={{width: '12%'}}>学生证缴费量</th>
                                    </thead>
                                    <tbody>
                                    {this.state.schoolDetailsTableData==""?'':SchoolDetailsTables}
                                    </tbody>
                                </table>
                                {this.state.schoolDetailsTableData==""?<div className="tableNoData">{tableNoDataCount}</div>:''}
                            </div>
                        </div>
                    </div>
                </div>
                {
                    /**
                     *点击查看学校
                     */
                }
                <div className="schooldetails" style={{display:pageView.schoolBarView==true?"block":"none"}}>
                    <header className="schooldetails-header">
                        <input type="hidden" id="deviceInfo"/>
                        <div className="schoolName"></div>
                        <div className="header-right">
                            <div className='header-right-select droup-select header-right-select-three'>
                                <div className="select-title">默认排序</div>
                                <span className="lower-right-corner" style={{left: "180px"}} />
                                <div className="drop-down select-sort" >
                                    <span className="select-value" onClick={svar.onClickSort.bind(svar,'')} >默认排序</span>
                                    <span className="select-value" onClick={svar.onClickSort.bind(svar,1)} >考勤卡激活量从低到高</span>
                                    <span className="select-value" onClick={svar.onClickSort.bind(svar,2)} >考勤卡激活量从高到低</span>
                                    <span className="select-value" onClick={svar.onClickSort.bind(svar,3)} >学生证缴费量从低到高</span>
                                    <span className="select-value" onClick={svar.onClickSort.bind(svar,4)} >学生证缴费量从高到低</span>
                                    <span className="select-value" onClick={svar.onClickSort.bind(svar,5)} >学生证激活量从低到高</span>
                                    <span className="select-value" onClick={svar.onClickSort.bind(svar,6)} >学生证激活量从高到低</span>
                                </div>
                            </div>
                            <div className="schoolReturn" onClick={this.onClickReturn}>
                                <img src="../img/icon/fanhui.png" alt=""/>
                                <span>返回</span>
                            </div>
                        </div>
                    </header>
                    <div className="parentsInfo tableInfo">
                        <div className="parentsInfo-data tableInfo-data">
                            <div className="parentsInfo-data-table tableInfo-data-table" >
                                <table className="head-body head-body">
                                    <thead>
                                        <th style={{width: '9%'}}>序号</th>
                                        <th style={{width: '15%'}}>班级</th>
                                        <th style={{width: '15%'}}>手机号</th>
                                        <th style={{width: '13%'}}>老师姓名</th>
                                        <th style={{width: '12%'}}>考勤卡发放量</th>
                                        <th style={{width: '12%'}}>考勤卡激活量</th>
                                        <th style={{width: '12%'}}>学生证激活量</th>
                                        <th style={{width: '12%'}}>学生证缴费量</th>
                                    </thead>
                                    <tbody>
                                        {this.state.schoolDetailsTableData==""?'':SchoolDetailsTables}
                                    </tbody>
                                </table>
                                {this.state.schoolDetailsTableData==""?<div className="tableNoData">{tableNoDataCount}</div>:''}
                            </div>
                        </div>
                    </div>
                </div>
                <footer id="copyright">
                    <span><img src="../img/icon/copyright.png"/>{copyright}</span>
                </footer>
            </div>
        )
    }
});
ReactDOM.render(
    <Main tableData={tableData} intelligentData={intelligentData} cardData={cardData} payPraceData={payPraceData} xAxisData={xAxisData}  schoolDataAll={schoolDataAll} schoolDataList={schoolDataList} addresData={addresData}
          addresDataOth={addresDataOth} ThiPointFXData={ThiPointFXData} pageView={pageView} schoolTableData={schoolTableData} schoolDetailsTableData={schoolDetailsTableData}/>,
    document.getElementById('tableManage')
);
$(window).resize(function () {
    var myChart = echarts.init(document.getElementById('dendrogram-centent'));
    myChart.showLoading();
    myChart.setOption(option);
    myChart.hideLoading();
});
/**
 * 点击下拉框
 */
$(".header-right-select-one").click(function () {
    var schoolClassTeacher = $(this).find('.schoolClassTeacher');
    $('.weekTrend').slideUp();
    if(schoolClassTeacher.is(":hidden")){
        schoolClassTeacher.slideDown();
    }else{
        schoolClassTeacher.slideUp();
    }
});
/**
 * 点击下拉框
 */
$(".header-right-select-two").click(function () {
    var weekTrend = $(this).find('.weekTrend');
    $('.schoolClassTeacher').slideUp();
    if(weekTrend.is(":hidden")){
        weekTrend.slideDown();
    }else{
        weekTrend.slideUp();
    }
});
/**
 * 点击下拉框
 */
$(".header-right-select-three").click(function () {
    var selectSort = $(this).find('.select-sort');
    if(selectSort.is(":hidden")){
        selectSort.slideDown();
    }else{
        selectSort.slideUp();
    }
});
/**
 * 选择-统计分析
 */
$('.schoolClassTeacher > span').click(function() {
    var value = $(this).html();

    if(value == "学校" && $(".school-or-classTeacher").html() != "学校"){
        $("#query_school_1").attr({"placeholder":"请输入学校筛选","maxLength":"50"});
        $("#query_school_1").val("");//输入框重新赋值
    }else if(value == "班主任"&& $(".school-or-classTeacher").html() != "班主任"){
        $("#query_school_1").attr({"placeholder":"请选择班主任手机号筛选","maxLength":"11"});
        $("#query_school_1").val("");//输入框重新赋值
    }else if(value == "按地区"&& $(".school-or-classTeacher").html() != "按地区"){
        $("#query_school_1").attr({"placeholder":"请选择省市区筛选","maxLength":"50"});
        $("#query_school_1").val("");//输入框重新赋值
    }
    $(".school-or-classTeacher").html($(this).html());
    $('.drop-down').slideUp();
});
/**
 * 选择-一周趋势
 */
$('.weekTrend > span').click(function() {
    var value = $(this).html();
    if(value == "按学校" && $(".school-or-address").html() != "按学校"){
        $("#query_school_2").attr("placeholder","请输入学校筛选");
        $("#query_school_2").val("");//输入框重新赋值
    }else if(value == "按地区" && $(".school-or-address").html() != "按地区"){
        $("#query_school_2").attr("placeholder","选择省市区");
        $("#query_school_2").val("");//输入框重新赋值
    }
    $(".school-or-address").html($(this).html());
    $('.drop-down').slideUp();
});
$('.frequencyTime').datetimepicker({
    format: "Y-m-d", //格式化日期
    timepicker: false, //显示时间选项
    todayButton: false, //关闭选择今天按钮
    step:5,//时间间隔
});
//学校下拉列表
$("*").bind("click",function(e){
    var target = $(e.target);
    if(target.closest(".schoolList-value").length == 1){
        if("query_school_2" == $(target.parent()).attr("data-inputId")){
            $("#"+$(target.parent()).attr("data-inputId")+"").val(target.html());
        }else{
            $("#"+$(target.parent()).attr("data-inputId")+"").val(target.html());
        }
        $(".schoolList").hide();
    }else if(target.closest(".addressesTwo").length == 1 || target.closest(".addressesOne").length == 1) {
    }else{
        $(".schoolList").hide();
        $(".addresses").hide();
    }
});
function keyUp(e) {
    var currKey=0,e=e||event;
    currKey=e.keyCode||e.which||e.charCode;
    var keyName = String.fromCharCode(currKey);
    if(currKey == 8){
        if($(".enterEvent1").is(":focus")){
            console.log($(".school-or-classTeacher").html());
            if($(".school-or-classTeacher").html() == "按地区"){
                $("#query_school_1").val("");
            }
        }else if($(".enterEvent2").is(":focus")){
            if($(".school-or-address").html() == "按地区"){
                $("#query_school_2").val("");
            }
        }
    }
}
document.onkeyup = keyUp;